package com.lanju.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lanju.common.SpringUtils;
import com.lanju.dao.HouseDao;
import com.lanju.dao.HouseFlagDao;
import com.lanju.entity.House;
import com.lanju.entity.HouseFlag;
import com.lanju.entity.User;
import com.lanju.service.HouseFlagService;
import com.lanju.util.SecurityContext;

@Service
public class HouseFlagServiceImpl implements HouseFlagService {

	@Autowired
	private HouseFlagDao houseFlagDao;
	
	@Override
	public Map<String, Object> getAllFlagList() {
		Map<String,Object> map=new HashMap<String, Object>();
		List<HouseFlag> list=houseFlagDao.getAllFlagList();
		map.put("rows", list);
		return map;
	}

	@Override
	@Transactional(value="financialmarketingTM", readOnly=true)
	public Map<String, Object> insertFlagType(Map<String, Object> param) {
		Map<String, Object> result = new HashMap<String, Object>();
		
		try {
			param.put("id", UUID.randomUUID().toString());
			houseFlagDao.insertFlagType(param);
			result.put("msg", true);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			result.put("msg", false);
		}
		return result;
	}
	
	@Override
	@Transactional(value="financialmarketingTM", readOnly=true)
	public Map<String, Object> delFlagType(Map<String, Object> param) {
		Map<String, Object> result = new HashMap<String, Object>();
		
		try {
			houseFlagDao.delFlagType(param);
			result.put("msg", true);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			result.put("msg", false);
		}
		return result;
	}
	
	@Override
	@Transactional(value="financialmarketingTM", readOnly=true)
	public Map<String, Object> updateFlagType(Map<String, Object> param) {
		Map<String, Object> result = new HashMap<String, Object>();
		
		try {
			houseFlagDao.updateFlagType(param);
			result.put("msg", true);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			result.put("msg", false);
		}
		return result;
	}
	
	@Override
	@Transactional(value="financialmarketingTM", readOnly=true)
	public Map<String, Object> queryFlagTypeList(Map<String, Object> param) {
		Map<String, Object> result = new HashMap<String, Object>();
		
		try {
			houseFlagDao.queryFlagTypeList(param);
			List<Map<String, Object>> list = houseFlagDao.queryFlagTypeList(param);
	        long count = houseFlagDao.countFlagTypeList(param);
	        result.put("total", count);
	        result.put("rows", list);
			result.put("msg", true);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			result.put("msg", false);
		}
		return result;
	}

}
